package apiday08.reflect;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

public class Test {
    public static void main(String[] args) throws Exception {
        Class cls = Class.forName("apiday08.reflect.Person");
        Object obj = cls.newInstance();
        Method[] methods = cls.getMethods();
        int count = 0;
        for (int i = 0; i < methods.length; i++) {
            if(methods[i].getModifiers()== Modifier.PUBLIC && methods[i].getParameterTypes().length==0){
                count++;
                System.out.println("public且为无参的方法："+methods[i].getName());
                Method method = methods[i];
                method.invoke(obj);           }
        }
        System.out.println("个数："+count);
    }
}
